var $ = require('jquery');
var html = require('./index.html');
var chatPeer = require('../../chatPeer');
var $noticeTmp = $(html);
module.exports.create = function (content, url, type) {
  var $notice = $noticeTmp.clone();
  var msgType = type || '系统消息';
  var html = '【' + msgType + '】 ' + content;
  if (url) {
    html += '<a href="' + url + '" target="_blank"> [查看详情]</a>';
  }
  $notice.find('p').html(html);
  $notice.find('.reconnect').on('click', function () {
    chatPeer.active(function (err) {
      var status = '重连成功';
      if (err) {
        status = '重连失败';
      }
      $notice.find('p').html(status);
    });
  });
  return $notice;
};
